Skip to content

Fixing path traversal/arbitrary out-of-directory file read via sharde…#14182

Merged
sayakpaul merged 4 commits into
huggingface:mainfrom
buffett0323:fix/shard-weight-map-path-traversal
Jul 17, 2026
Merged

Fixing path traversal/arbitrary out-of-directory file read via sharde…#14182
sayakpaul merged 4 commits into
huggingface:mainfrom
buffett0323:fix/shard-weight-map-path-traversal

Conversation

@buffett0323

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a path-traversal vulnerability in sharded-checkpoint loading. Validate every shard filename right after parsing the index by rejecting any value where os.path.basename(f) != f. This can reject absolute paths, ../ traversal, and subdirectory components in one guard.

Fixes #14175

Before submitting

Who can review?

@yiyixuxu @DN6 @sayakpaul

@sayakpaul
sayakpaul requested a review from DN6 July 14, 2026 03:32
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@DN6 DN6 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @buffett0323 👍🏽

@buffett0323

Copy link
Copy Markdown
Contributor Author

@DN6 @sayakpaul thanks for your help!
I checked the 2 red CI checks, they are unrelated to this change. Could you help merge this PR? thanks!

@sayakpaul
sayakpaul merged commit cee298c into huggingface:main Jul 17, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Path traversal / arbitrary out-of-directory file read via sharded-checkpoint weight_map in _get_checkpoint_shard_files

4 participants